/*  
 *  Nanjing JIYU Technology Co.,Ltd All rights reserved.
 *  Copyright (C) 2022 
 *  ==============================================================
 * 
 *  main.c 
 *    主循环，传送带控制逻辑
 *
 *  --------------------------------------------------------------
 *  
 */

#include "main.h"

#include "status.h"

#include "device.h"
#include "peripheral.h"

#define MAXSPEED  300

extern void motor_pwm_set1(int p); 
extern void motor_pwm_set1(int p); 
extern void motor_pwm_set1(int p);
extern void motor_pwm_set1(int p);



int main(void)
{
  HAL_Init();                     /* HAL相关功能初始化 */
  system_clock_init();            /* 系统时钟设置与延时功能设置 */
	
  peripheral_init();              /* MCU外设初始化 */
	
	motor_pwm_set2(-200); 	//传送带
	
	HAL_Delay(500);
	
	motor_pwm_set2(0);
	motor_pwm_set3(0);
	
	int F1_Flag = 0;
	int F2_Flag = 0;
	
  while (1)
  {
		
		//motor_transporter_pwm_set(200);
		
    if (GRAY_S0 == 0)
    {
			delay_ms(1500);
      F1_Flag = 1;
		}
	
		if(F1_Flag == 1)
		{
			motor_transporter_pwm_set(-250);
			
		  //for (int i=0; i<MAXSPEED; i = i+10)
      //{
      //  motor_transporter_pwm_set(i);
      //  delay_ms(50);
      //}
		}
		
    if (GRAY_S1 == 0)
    {
      delay_ms(1000);
		  F2_Flag = 1;
     
    }
		
		if(F2_Flag == 1)
		{
			motor_fire_pwm_set(-930);
			delay_ms(600);
			motor_fire_pwm_set(0);
				
			delay_ms(500);
			motor_fire_pwm_set(300);
			delay_ms(400);
			motor_fire_pwm_set(0);
			
			F1_Flag = 0;
			F2_Flag = 0;
		}
		else
		{
			motor_fire_pwm_set(0);
		}
		
		
    //delay_ms(50);
		
  }
}

